<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <title>Find &amp; Replace</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <link href="../../stylesheet.css" type="text/css" rel="stylesheet"/>
<link href="../../page_styles1.css" type="text/css" rel="stylesheet"/>

  


<link href="../../calibreHtmlOutBasicCss.css" type="text/css" rel="stylesheet" />

</head>
<body>

<div class="calibreMeta">
  <div class="calibreMetaTitle">
  
  
    
    <h1>
      <a href="../../../index.html">Sigil User Guide
</a>
    </h1>
    
    
  
  </div>
  <div class="calibreMetaAuthor">
    0.7.2

  </div>
</div>

<div class="calibreMain">

  <div class="calibreEbookContent">
    
      <div class="calibreEbNavTop">
        
          <a href="splitting_and_merging.html" class="calibreAPrev">previous page</a>
        

        
          <a href="saved_searches.html" class="calibreANext"> next page</a>
        
      </div>
    

    
  <h2 id="find_and_replace" class="calibre5">Find &amp; Replace</h2>

  <p class="h2subheading">— Searching In Code View —</p>

  <p class="calibre1">Finding text and updating it is one of the most common tasks in Sigil – to look for words, to remove unwanted text in one file, or to change the formatting of specific items in the entire book. In fact, if you ever need to make lots of changes to your text you will almost certainly want to use Find &amp; Replace (and its related <a href="../Text/saved_searches.html">Saved Searches</a> feature) since it allows you to quickly make a large number of edits across all your files.</p>

  <div class="tip">
    <p class="tiptext">See the <a href="../Text/tutorial_regex_reference.html">Regex</a> tutorial for information about advanced searching.</p>
  </div>

  <p class="calibre1">To open the Find &amp; Replace dialog, select the menu item <span class="shortcut">Search→Find &amp; Replace</span> or its keyboard shortcut:</p>

  <div class="image"><img alt="find-replace-options" src="../Images/find-replace-options.png" class="calibre7"/></div>

  <div class="tip">
    <p class="tiptext">Book View only supports finding text in the current file – all other actions will be done in Code View.</p>
  </div>

  <p class="calibre1">You can set various modes (Normal, Case-Sensitive, Regex, search some or all HTML files or just selected text, search down/up, etc.) and options (Wrap, DotAll, etc.) to modify the behaviour of the actions (find, replace, replace all, etc.) you select, e.g:</p>

  <div class="image"><img alt="find-replace-options-example" src="../Images/find-replace-options-example.png" class="calibre7"/></div>

  <p class="calibre1">When open, the Find &amp; Replace dialog is always positioned at the bottom of the editing window for easy access. You can use the buttons on the lower left to show or hide Options.</p>

  <div class="tip">
    <p class="tiptext">Keyboard shortcuts exist for all find and replace operations – such as <span class="menuitem">Ctrl+G</span> to find again. See the <span class="menuitem">Search</span> menu for a list of shortcuts.</p>
  </div>

  <h3 class="sigilnotintoc" id="find_actions">Actions</h3>

  <p class="calibre1">The buttons on the right are used to run your search commands.</p>

  <div class="tip">
    <p class="tiptext">After you run a search, the text you entered in either the Find or Replace box is saved and is available for you to select later. Click the down-arrow to the right of the Find (or Replace) text box to show the list of items in the search histories.</p>

    <p class="tiptext">Whenever you run a search, the results are shown in the Find &amp; Replace status bar.</p>
  </div>

  <h4 class="sigilnotintoc1">Find</h4>

  <p class="calibre1">Finds the next occurrence of your search term and highlights it.</p>

  <p class="calibre1">To search for text, enter it in in the Find text box and press the <span class="buttonbox">Find</span> button. Any text in the Replace box is ignored if you are just doing a Find.</p>

  <div class="tip">
    <p class="tiptext">If you select text in your document, you can use <span class="menuitem">Ctrl+F</span> to open Find &amp; Replace window and your selected text will be placed in the Find box.</p>
  </div>

  <h4 class="sigilnotintoc1">Replace</h4>

  <p class="calibre1">Replaces one occurrence of the text matched by Find.</p>

  <div class="tip">
    <p class="tiptext">Replaces are done in Code View so you must first run Find in Code View.</p>
  </div>

  <p class="calibre1">To replace text:</p>

  <ul class="calibre3">
    <li class="calibre4">Enter the text to find in the Find box.</li>

    <li class="calibre4">Enter the text you want to replace it with in Replace box.</li>

    <li class="calibre4">Select <span class="buttonbox">Find</span> to search for and highlight a match.</li>

    <li class="calibre4">Select <span class="buttonbox">Replace</span> to do the replacement.</li>
  </ul>

  <div class="tip">
    <p class="tiptext">To undo changes you can use the Undo button <img alt="" src="../Images/edit-undo_22px.png" class="calibre7"/> or right-click in the editing window and select <span class="menuitem">Undo</span> to change the text back. But if you are replacing across files and your next match is on a different page, you need to switch back to the file containing the replaced text before selecting undo.</p>
  </div>

  <h4 class="sigilnotintoc1">Replace/Find</h4>

  <p class="calibre1">Replaces one occurrence of the next matched by Find and then runs Find automatically to highlight the next match.</p>

  <p class="calibre1">To replace text, enter the old text in the Find box, and the new text in the Replace box. Then click <span class="buttonbox">Replace/Find</span>.</p>

  <p class="calibre1">The first time you do a <span class="buttonbox">Replace/Find</span> the first match will be highlighted. Subsequent use of <span class="buttonbox">Replace/Find</span> will replace the highlighted matched text and then automatically Find the next match.</p>

  <div class="tip">
    <p class="tiptext">You can safely use Replace/Find instead of Find if no text is selected since it will act just like Find until a match is highlighted.</p>
  </div>

  <h4 class="sigilnotintoc1">Replace All</h4>

  <p class="calibre1">Replaces all text matching your search term with your replace term according to your settings. This is done all at once automatically.</p>

  <div class="tip">
    <p class="tiptext">You cannot undo a Replace All – save first!</p>
  </div>

  <p class="calibre1"><span class="buttonbox">Replace All</span> always replaces from the start of a file.</p>

  <div class="tip">
    <p class="tiptext">Test your find and replace strings using Count All, or Replace a few times before using Replace All to avoid surprises.</p>

    <p class="tiptext">Save your book before a Replace All and check it after the replace in case of issues.</p>

    <p class="tiptext">Check if your mode is set for <span class="buttonbox1">Current File</span> or <span class="buttonbox1">All HTML Files</span></p>
  </div>

  <h4 class="sigilnotintoc1" id="count_all">Count All</h4>

  <p class="calibre1">Count All can be displayed using the Options button (see below) – or you can use its keyboard shortcut.</p>

  <p class="calibre1">Count All displays a count of the number of times the search term you entered in the Find text box occurs in the selected files. It uses the settings of both the Up/Down modes and the Wrap option.</p>

  <div class="tip">
    <p class="tiptext">It's a good idea to use <span class="buttonbox1">Count All</span> before doing a replace to check the number of replacements are what you expect. And you should run it after a Replace All in case the particular search and replace created new matches.</p>
  </div>

  <h3 class="sigilnotintoc" id="find_what">Mode – What to Search</h3>

  <p class="calibre1">You can control what type of text to search for using these options.</p>

  <h4 class="sigilnotintoc1">Normal</h4>

  <p class="calibre1">This mode will search for exactly what you type except that it will ignore case, e.g. “A” and “a” will be considered the same letter.</p>

  <h4 class="sigilnotintoc1">Case Sensitive</h4>

  <p class="calibre1">This mode will search for exactly what you type.</p>

  <h4 class="sigilnotintoc1">Regex</h4>

  <p class="calibre1">Regex is an abbreviation of “Regular Expression”. This mode allows you to search for patterns instead of exact words or characters. Regex is very powerful and one of the main benefits of using Sigil to work with ebooks.</p>

  <p class="calibre1">For instance, you can search for “Page [0-9]+” which will find "Page " followed by one or more numbers.</p>

  <div class="tip">
    <p class="tiptext">See the <a href="../Text/tutorial_regex_reference.html">Regular Expressions</a> chapter for more details about using regex.</p>
  </div>

  <h4 class="sigilnotintoc1">Mode – Where to Search</h4>

  <p class="calibre1">You can control which files to search with these options making it easy to search all or just some of your files.</p>

  <h4 class="sigilnotintoc1">Current File</h4>

  <p class="calibre1">This restricts your search to just the file you are viewing. You can search HTML files and Style files.</p>

  <p class="calibre1">If your search reaches the end of the file and wrap is on it will automatically wrap around and search from the other end of the file. You will see a small picture of an arrow flash on the screen to indicate the search wrapped around.</p>

  <div class="tip">
    <p class="tiptext">If you hold the <span class="menuitem">Ctrl</span> key down while clicking on an action you will be able to temporarily run the search only on the Current File.</p>
  </div>

  <h4 class="sigilnotintoc1">All HTML Files</h4>

  <p class="calibre1">This searches in every HTML file. It does not search in every file – just every HTML file.</p>

  <p class="calibre1">When a search reaches the end or beginning of the book it will automatically move to the next or previous file (in the order listed in the book browser), and it will loop around when all files have been searched if wrap is on.</p>

  <h4 class="sigilnotintoc1">Selected HTML Files</h4>

  <p class="calibre1">This searches only the HTML files that you selected in the Book Browser.</p>

  <p class="calibre1">When a search reaches the end of a file it will automatically move to the next or previous selected file (in the order listed in the book browser), and it will loop around when all files have been searched if wrap is on.</p>

  <h4 class="sigilnotintoc1">Marked Text</h4>

  <p class="calibre1">This is a special option that is only shown when you mark text.</p>

  <p class="calibre1">You can restrict your search to a selection of text by marking that text. To mark text, select some text in Code View and then use the <span class="shortcut">Search→Mark Selected Text</span> or use the right-click context menu to select <span class="shortcut">Mark Selected Text</span>.</p>

  <p class="calibre1">Text can be unmarked by using the menu item again without a selection.</p>

  <p class="calibre1">Text will be unmarked if you use Undo, type any text, or change views or tabs. If you just use Replace or Replace All, the marked text will be expanded or shrunk appropriately.</p>

  <h3 class="sigilnotintoc">Mode – Search Direction</h3>

  <p class="calibre1">You can control the direction of searching with these options.</p>

  <h4 class="sigilnotintoc1">Up</h4>

  <p class="calibre1">Searches from your position in the document upwards and finds the previous occurrence of your search.</p>

  <h4 class="sigilnotintoc1">Down</h4>

  <p class="calibre1">Searches from your position in the document downwards and finds the next occurrence of your search.</p>

  <h3 class="sigilnotintoc">Options</h3>

  <p class="calibre1">Find &amp; Replace provides several options when using Regex mode.</p>

  <p class="calibre1">Click the show button <img alt="" src="../Images/chevron-down_16px.png" class="calibre7"/> on the Find &amp; Replace window to expand the window if it’s not already expanded to show the options and the button <span class="buttonbox">Count All</span>:</p>

  <div class="image"><img alt="find-replace-options" src="../Images/find-replace-options.png" class="calibre7"/></div>

  <p class="calibre1">Click the hide button <img alt="" src="../Images/chevron-up_16px.png" class="calibre7"/> to hide the options:</p>

  <div class="image"><img alt="find-replace-basic" src="../Images/find-replace-basic.png" class="calibre7"/></div>

  <h4 class="sigilnotintoc1">DotAll</h4>

  <p class="calibre1">This regex option prepends (?s) to all regex searches and is used when you want the ".*" pattern to match any character even across lines.</p>

  <h4 class="sigilnotintoc1">Minimal Match</h4>

  <p class="calibre1">This regex option prepends (?U) to all regex searches and is used when you want a pattern to match the shortest occurrence instead of the longest match.</p>

  <h4 class="sigilnotintoc1">Auto-Tokenise</h4>

  <p class="calibre1">When using Ctrl-F on selected text to add text to Find &amp; Replace, this will convert spaces to \s and escape certain characters so they are suitable for regex.</p>

  <h4 class="sigilnotintoc1">Wrap</h4>

  <p class="calibre1">When enabled, searches in the Current File will automatically wrap around from the bottom of the file to the top to look for your text (or the reverse if searching Up). When disabled, searches will stop at the end of the file.</p>

  <p class="calibre1">When you are searching in All HTML Files, then when wrap is enabled if your search reaches the last HTML file the search will continue automatically from the first HTML file to look for your text (or the reverse if searching Up). When disabled, searches will stop at the last file in the book (or the first if searching Up).</p>

  <h3 class="sigilnotintoc">Context Menu</h3>

  <p class="calibre1">If you right-click on the Find or Replace box you are given various options:</p>

  <ul class="calibre3">
    <li class="calibre4"><span class="listheading"><i class="calibre10">Saved Searches</i>:</span> A list of Saved Searches you can select to load into Find &amp; Replace.</li>

    <li class="calibre4"><span class="listheading">Save Search:</span> Save this Find &amp; Replace search in Saved Searches.</li>

    <li class="calibre4"><span class="listheading">Tokenise Selection:</span> Convert spaces to \s and escape certain characters.</li>
  </ul>



  </div>

  
  <div class="calibreToc">
    <h2><a href="../../../index.html"> Table of contents</a></h2>
     <div>
  <ul>
    <li>
      <a href="cover_picture.html">Cover</a>
    </li>
    <li>
      <a href="titlepage.html">Title Page</a>
    </li>
    <li>
      <a href="rights.html">Copyright</a>
    </li>
    <li>
      <a href="introduction.html">Introduction</a>
      <ul>
        <li>
          <a href="whats_new.html">What’s New</a>
        </li>
        <li>
          <a href="about_sigil.html">About Sigil</a>
        </li>
        <li>
          <a href="about_epub.html">About EPUB</a>
        </li>
      </ul>
    </li>
    <li>
      <a href="installation.html">Installation</a>
    </li>
    <li>
      <a href="features.html">Features</a>
      <ul>
        <li>
          <a href="user_interface.html">User Interface</a>
        </li>
        <li>
          <a href="preferences.html">Preferences</a>
        </li>
        <li>
          <a href="opening_and_saving_files.html">Opening and Saving Files</a>
        </li>
        <li>
          <a href="book_view.html">Book View</a>
        </li>
        <li>
          <a href="code_view.html">Code View</a>
        </li>
        <li>
          <a href="preview.html">Preview</a>
        </li>
        <li>
          <a href="book_browser.html">Book Browser</a>
        </li>
        <li>
          <a href="metadata.html">Metadata</a>
        </li>
        <li>
          <a href="add_cover.html">Add Cover</a>
        </li>
        <li>
          <a href="table_of_contents.html">Table of Contents</a>
        </li>
        <li>
          <a href="validation.html">Validation</a>
        </li>
        <li>
          <a href="spellcheck.html">Spellcheck</a>
        </li>
        <li>
          <a href="media_files.html">Images, Video, Audio</a>
        </li>
        <li>
          <a href="special_characters.html">Special Characters</a>
        </li>
        <li>
          <a href="splitting_and_merging.html">Splitting and Merging</a>
        </li>
        <li>
          <a href="find_replace.html">Find &amp; Replace</a>
        </li>
        <li>
          <a href="saved_searches.html">Saved Searches</a>
        </li>
        <li>
          <a href="clips.html">Clips</a>
        </li>
        <li>
          <a href="clipboard_history.html">Clipboard History</a>
        </li>
        <li>
          <a href="links.html">Links and IDs</a>
        </li>
        <li>
          <a href="styles.html">Styles</a>
        </li>
        <li>
          <a href="indexes.html">Indexes</a>
        </li>
        <li>
          <a href="reports.html">Reports</a>
        </li>
        <li>
          <a href="external_editors.html">External Editors</a>
        </li>
      </ul>
    </li>
    <li>
      <a href="tutorials.html">Tutorials</a>
      <ul>
        <li>
          <a href="tutorial_getting_started_with_epub.html">Getting Started With EPUB</a>
        </li>
        <li>
          <a href="tutorial_convert_to_html.html">Prepare Your File For Sigil</a>
        </li>
        <li>
          <a href="tutorial_load_file.html">Open Your File With Sigil</a>
        </li>
        <li>
          <a href="tutorial_save.html">Save Your EPUB File</a>
        </li>
        <li>
          <a href="tutorial_metadata.html">Add the Author and Title</a>
        </li>
        <li>
          <a href="tutorial_add_cover.html">Add a Cover Image</a>
        </li>
        <li>
          <a href="tutorial_split.html">Create Files For Each Chapter</a>
        </li>
        <li>
          <a href="tutorial_mark_chapters.html">Identify Your Chapters</a>
        </li>
        <li>
          <a href="tutorial_generate_toc.html">Generate A Table of Contents</a>
        </li>
        <li>
          <a href="tutorial_links.html">Create Links and Notes</a>
        </li>
        <li>
          <a href="tutorial_code_view.html">A Quick Introduction To Code View</a>
        </li>
        <li>
          <a href="tutorial_spelling.html">Check For Spelling Mistakes</a>
        </li>
        <li>
          <a href="tutorial_validate.html">Check For Errors In Your EPUB</a>
        </li>
        <li>
          <a href="tutorial_find_replace.html">Edit With Find &amp; Replace</a>
        </li>
        <li>
          <a href="tutorial_stylesheets.html">Use Stylesheets</a>
        </li>
        <li>
          <a href="tutorial_embed_fonts.html">Include Custom Fonts</a>
        </li>
        <li>
          <a href="tutorial_advanced_find.html">Advanced Find &amp; Replace – Regex</a>
        </li>
        <li>
          <a href="tutorial_regex_reference.html">Regular Expression Reference</a>
        </li>
        <li>
          <a href="tutorial_tips.html">Tips</a>
        </li>
      </ul>
    </li>
    <li>
      <a href="faq.html">FAQ</a>
      <ul>
        <li>
          <a href="faq.html#faq_common_questions">Common Questions</a>
        </li>
        <li>
          <a href="faq.html#faq_questions">Where to Get Help</a>
        </li>
        <li>
          <a href="faq.html#faq_using_sigil">Using Sigil</a>
        </li>
        <li>
          <a href="faq.html#faq_formatting">Formatting and Styles</a>
        </li>
      </ul>
    </li>
    <li>
      <a href="contributing_to_sigil.html">Contributing to Sigil</a>
    </li>
  </ul>
</div>


  </div>
  

  <div class="calibreEbNav">
    
      <a href="splitting_and_merging.html" class="calibreAPrev">previous page</a>
    

    <a href="../../../index.html" class="calibreAHome"> start</a>

    
      <a href="saved_searches.html" class="calibreANext"> next page</a>
    
  </div>

</div>

</body>
</html>
